/*
 * Project: yygh-parent
 *
 * File Created at 2023/7/8
 *
 * 自定义时间格式代替DATE标签：2023-07-08 19:17:19:17
 */
package com.atguigu.yygh;

import com.atguigu.yygh.order.mapper.DictMapper;
import com.atguigu.yygh.model.cmn.Dict;
import com.atguigu.yygh.order.service.DictService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @author 用户名
 * @Type ServiceCmnApplicationTestes.java
 * @Desc
 * @date 2023/7/8 19:17
 */
@SpringBootTest(classes = ServiceCmnApplication.class)
 class ServiceCmnApplicationTestes {
    @Autowired
    DictMapper dictMapper;
    @Autowired
    DictService dictService;
    @Test
    public void test01(){
        QueryWrapper<Dict> wrapper = new QueryWrapper<>();
        wrapper.eq("parent_id",1);
        List<Dict> dicts = dictMapper.selectList(wrapper);
        for (Dict dict : dicts) {
            boolean hasChild = HasChild(dict.getId());
            dict.setHasChildren(hasChild);
            System.out.println("打印");
            System.out.println(dict);
        }

    }

    public boolean HasChild(Long id){
        QueryWrapper<Dict> wrapper = new QueryWrapper<>();
        wrapper.eq("parent_id",id);
        Integer integer = dictMapper.selectCount(wrapper);
        if (integer>0){
            return true;
        }

        return false;
    }
    @Test
    public void testSql01(){

        QueryWrapper<Dict> wrapper = new QueryWrapper<>();
        wrapper.eq("value","86");
        Dict dict = dictMapper.selectOne(wrapper);

        System.out.println(dict);
    }


}


/**
 * Revision history
 * -------------------------------------------------------------------------
 * <p>
 * Date Author Note
 * -------------------------------------------------------------------------
 * 2023/7/8 用户名 create
 */ 
